package com.wigem.approve.controller;

import com.wigem.approve.entity.DaqEstateEntity;
import com.wigem.framework.common.pojo.PageResult;
import com.wigem.framework.common.util.web.response.Result;
import com.wigem.framework.common.util.web.response.ResultController;

import java.util.List;

import com.wigem.approve.entity.DaqEnterpriseEntity;
import com.wigem.approve.service.DaqEnterpriseService;
import com.wigem.approve.vo.DaqEnterpriseVo;
import com.wigem.framework.common.util.web.response.module.ResultTable;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.swing.text.html.parser.Entity;

import static com.wigem.framework.common.util.web.response.module.ResultTable.pageTable;

/**
 * 楼宇入驻企业填报Controller
 *
 * @author DH
 * @date 2024-05-26
 */
@RestController
@RequestMapping("/approve/enterprise")
public class DaqEnterpriseController extends ResultController {


    @Resource
    private DaqEnterpriseService daqEnterpriseService;

    /**
     * 查询楼宇入驻企业填报列表
     */
    @ResponseBody
    @GetMapping("/query")
    public Result getList(DaqEnterpriseVo daqEnterpriseVo) {

        return success(daqEnterpriseService.getList(daqEnterpriseVo));
    }
    @ResponseBody
    @GetMapping("/export/query")
    public Result getExportList(DaqEnterpriseVo daqEnterpriseVo) {
        return success(daqEnterpriseService.getExportPageList(daqEnterpriseVo));
    }

    /**
     * 查询楼宇入驻企业填报列表
     */
    @ResponseBody
    @GetMapping("/query/page")
    public ResultTable getPageList(DaqEnterpriseVo daqEnterpriseVo) {
        PageResult<DaqEnterpriseEntity> pageInfo = daqEnterpriseService.getPageList(daqEnterpriseVo);
        return  pageTable(pageInfo.getTotal(), pageInfo.getList());
    }
    @ResponseBody
    @GetMapping("/manage/query/page")
    public ResultTable getManagePageList(DaqEnterpriseVo daqEnterpriseVo) {
        PageResult<DaqEnterpriseEntity> pageInfo = daqEnterpriseService.getManagePageList(daqEnterpriseVo);
        return  pageTable(pageInfo.getTotal(), pageInfo.getList());
    }

    /**
     * 查询楼宇入驻企业填报实体
     */
    @ResponseBody
    @GetMapping("/query/{id}")
    public Result getEntity(@PathVariable("id") String id) {
        return success(daqEnterpriseService.getEntity(id));
    }


    /**
     * 楼宇入驻企业填报新增
     */
    @ResponseBody
    @PostMapping
    public Result add(@RequestBody DaqEnterpriseVo daqEnterpriseVo) {
        daqEnterpriseService.add(daqEnterpriseVo);
        return success("保存成功");
    }

    /**
     * 楼宇入驻企业填报修改
     */
    @ResponseBody
    @PutMapping
    public Result update(@RequestBody DaqEnterpriseVo daqEnterpriseVo) {
        daqEnterpriseService.update(daqEnterpriseVo);
        return success("修改成功");
    }


    /**
     * 新增保存
     */
    @ResponseBody
    @PostMapping("/save")
    public Result save(@RequestBody DaqEnterpriseVo daqEnterpriseVo) {
        daqEnterpriseService.save(daqEnterpriseVo);
        return success("保存成功！");
    }


    /**
     * 删除
     */
    @ResponseBody
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        daqEnterpriseService.delete(id);
        return success("删除成功！");
    }

    /**
     * 移除/逻辑删除
     */
    @ResponseBody
    @GetMapping("/remove/{id}")
    public Result remove(@PathVariable("id") String id) {
        daqEnterpriseService.remove(id);
        return success("删除成功！");
    }
}
